-- UINewDungeonEffect
-- Create by chengb Feb/5/2015
-- 新关卡字体跳动效果

UINewDungeonEffect = class("UINewDungeonEffect", function() 
    return cc.Layer:create();
end);

function UINewDungeonEffect.create()
    return UINewDungeonEffect.new();
end

-- 构造函数
function UINewDungeonEffect:ctor(options)
    self:setName("UINewDungeonEffect");
    
    -- 初始化
    local node = cc.CSLoader:createNode("layout/main/NewDungeonEffect.csb");
    self.node = node;
    self:addChild(node);
	
    self.newDungeons1 = findChildByName(node, "new");
    self.newDungeons2 = findChildByName(node, "new2");
    self.newDungeons3 = findChildByName(node, "new3");	
    
    self.newDungeons1:loadTexture(getLocImg("new"));
    self.newDungeons2:loadTexture(getLocImg("new2"));
    self.newDungeons3:loadTexture(getLocImg("new3"));

	self.newflag = 1;	
	
	local function jump() 
		local jumps = 1;
		local height = 5;
		
		local jumpBy = cc.JumpBy:create(0.3 * jumps, cc.p(0, 0), height, jumps);
        local jumpBy2 = cc.JumpBy:create(0.3 * jumps, cc.p(0, 0), height, jumps);
        local jumpBy3 = cc.JumpBy:create(0.3 * jumps, cc.p(0, 0), height, jumps);
		
		-- 分开跳动
		if self.newflag == 1 then
			self.newflag = 2;
            self.newDungeons1:runAction(jumpBy);
		elseif self.newflag == 2 then
			self.newflag = 3;
            self.newDungeons2:runAction(jumpBy2);
		elseif self.newflag == 3 then
			self.newflag = 4;
            self.newDungeons3:runAction(jumpBy3);
		else
			self.newflag = 1;
		end           
		
		performWithDelay(self, jump, 0.3);
	end

	-- 让字体跳动
	jump();
end
